package itsm.isperp.module.service.app;

import itsm.isperp.framework.data.domain.DataRequest;
import itsm.isperp.framework.data.domain.DataResponse;
import itsm.isperp.framework.web.request.JqGridRequest;
import itsm.isperp.module.dto.app.VUserAccount;
import itsm.isperp.module.repository.app.VUserAccountMapper;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * 用户account管理服务
 * 
 * @version V1.0
 */
@Service
public class UserAccountService {

	@Autowired
	protected VUserAccountMapper vUserAccountMapper;

	public VUserAccount findOne(String id, String... selectColumns) {
		return this.vUserAccountMapper.findOne(id, selectColumns);
	}

	public VUserAccount findByUsername(String username, String... selectColumns) {
		return this.vUserAccountMapper.findByUsername(username);

	}

	public DataResponse<VUserAccount> findAllByRequest(DataRequest req) {
		return this.vUserAccountMapper.findAllByRequest(req);
	}

	public List<VUserAccount> findAll() {
		return this.vUserAccountMapper.findAll();

	}

	public List<VUserAccount> findByPostion(String postion) {
		return this.vUserAccountMapper.findByPostion(postion);
	}

	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException {
		return this.vUserAccountMapper.findByUsername(username);
	}

	public DataResponse<VUserAccount> findAll(JqGridRequest req) {
		return this.vUserAccountMapper.findAllByRequest(req);
	}
}
